package com.example.demoboot.conditional;


import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by @author yihui in 09:15 18/10/18.
 */
@Configuration
@ConditionalOnClass(DependedClz.class)
public class ConditionDependAutoConfig {
    @Bean
    public DependedBean dependedBean() {
        return new DependedBean();
    }

    @Bean
    @ConditionalOnBean(name="dependedBean")
    public LoadIfBeanExist loadIfBeanExist() {

        return new LoadIfBeanExist("test");
    }




    @Bean
    @ConditionalOnClass(DependedClz.class)
    public LoadIfClzExists loadIfClzExists() {

        return new LoadIfClzExists("LoadIfClzExists");
    }
}